﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IWMAG.Scripting.AST.ObjectModel;
using IWMAG.Scripting.Interpreter;

namespace IWMAG.Scripting.AST.Statements {
    internal class ExpressionStatement : CodeStatement {
        public CodeExpression Expression;

        public ExpressionStatement(Compiler.Lexeme l, CodeExpression expr) : base(l) {
            Expression = expr;
        }

        public override void Verify(Helpers.CompileTable sym, List<Compiler.IUserInfo> error) {
            Expression.Verify(sym, error);
        }

        public override IEnumerable<Continuation> Execute(Interpreter.ScriptEngine engine, Helpers.RuntimeTable sym) {
            Reference<RunValue> val = RunValue.NoValue;

            foreach (Continuation wait in Expression.ValueOf(engine, sym, val)) yield return wait;
        }
    }
}
